package com.xiaoze.steampy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 小泽
 * @create 2022-03-30  16:26
 * 记得每天敲代码哦
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //所有img/singerPic/**开头的请求 都会去后面配置的路径下查找资源
        //定位歌手头像地址
        registry.addResourceHandler("/img/pic/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"img"
                        +System.getProperty("file.separator")+"pic"+System.getProperty("file.separator")
        );

        //定位歌手头像地址
        registry.addResourceHandler("/img/game/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"img"
                        +System.getProperty("file.separator")+"game"+System.getProperty("file.separator")
        );
    }
}

